package org.opportunity.wishlist.travelwish.pojo.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "focus")
public class Focus implements Serializable, Comparable<Focus> {

    private static final long serialVersionUID = -9086731177367167173L;

    private long id;
    private String propertyName;
    private String propertyDescription;
    private Facet facet;
    private Integer priority;

    public Focus() {
    }

    @Id
    @GeneratedValue
    @Column(name = "id")
    public long getId() {
	return id;
    }

    public void setId(long id) {
	this.id = id;
    }

    @ManyToOne
    public Facet getFacet() {
	return facet;
    }

    public void setFacet(Facet facet) {
	this.facet = facet;
    }

    @Column(name = "property_name")
    public String getPropertyName() {
	return propertyName;
    }

    public void setPropertyName(String propertyName) {
	this.propertyName = propertyName;
    }

    @Column(name = "property_description")
    public String getPropertyDescription() {
	return propertyDescription;
    }

    public void setPropertyDescription(String propertyDescription) {
	this.propertyDescription = propertyDescription;
    }

    @Column(name = "priority")
    public Integer getPriority() {
	return priority;
    }

    public void setPriority(Integer priority) {
	this.priority = priority;
    }

    @Override
    public int compareTo(Focus obj) {
	int lastCmp = this.priority.compareTo(obj.priority);
	return (lastCmp != 0 ? lastCmp : this.propertyName
		.compareToIgnoreCase(obj.propertyName));
    }

    @Override
    public boolean equals(Object obj) {
	if (!(obj instanceof Focus)) {
	    return false;
	}
	Focus focus = (Focus) obj;
	return focus.propertyName.equals(this.propertyName);
    }

}
